<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>JavaScript获取字符串长度</title>
    </head>
    <body>
        <h3>JavaScript获取字符串长度</h3>
        <hr />
        <script>
            //声明变量msg
            var msg = "Hello JavaScript!";
            //获取字符串长度
			var len = msg.length;
            alert("Hello JavaScript!的字符串长度为："+len);
        </script>
    </body>
</html>